/******************************************************************************
**                                                                           **
**                 Proprietary and Confidential Information                  **
**                                                                           **
**                 Copyright (c) SigmaTel, Inc. Unpublished                  **
**                                                                           **
** This source code and the algorithms implemented therein constitute        **
** confidential information and may compromise trade secrets of SigmaTel,    **
** Inc. or its associates, and any unauthorized use thereof is prohibited.   **
**                                                                           **
******************************************************************************/

/******************************************************************************
*  FILE FORMAT:
*      1. INCLUDES 
*      2. ENUMERATIONS 
*      3. DEFINES
*      4. STRUCTURES
*      5. GLOBALS
*      6. PRIVATE FUNCTION PROTOTYPES
*      7. FUNCTIONS
******************************************************************************/

#ifndef __DC_CONIP_ETC_API_H__
#define __DC_CONIP_ETC_API_H__

/******************************************************************************
*  1. INCLUDES
******************************************************************************/
#include "ospl.h"
#include "dc_type.h"
#include "ra_ip.h"
#include "dc_cm_common_api.h"

/******************************************************************************
*  2. ENUMERATIONS
******************************************************************************/

/******************************************************************************
*  3. DEFINES
******************************************************************************/
#define DC_CONIP_MAX_CHANNEL_COUNT           6
#define DC_CONIP_TRC_TABLE_COUNT             DC_CONIP_MAX_CHANNEL_COUNT

#define DC_CONIP_DITHER_TABLE_COUNT          8
#define DC_CONIP_DITHER_COMPONENT_COUNT      DC_CONIP_MAX_CHANNEL_COUNT

#define DC_CONIP_DITHER_CLASS_COUNT              4
#define DC_CONIP_CSC_CLASS_COUNT                 4

#define DC_CONIP_CSC_CONTROL_ONCHIP_LUT          (0x01)
#define DC_CONIP_CSC_CONTROL_ONCHIP_SPEEDUP      (0x10)
#define DC_CONIP_CSC_CONTROL_INTERPOLATION_TYPE  (0x20)
#define DC_CONIP_CSC_CONTROL_NO_SATURATE         (0x40)
#define DC_CONIP_CSC_CONTROL_MONO_ON_DIAGONAL    (0x80)

#define DC_CONIP_CSC_CONTROLEXT_TRUE6COLOR       (0x01)
#define DC_CONIP_CSC_CONTROLEXT_CACHEENABLE      (0x02)
#define DC_CONIP_CSC_CONTROLEXT_HYBRIDTABLES     (0x04)

/******************************************************************************
*  4. STRUCTURES
******************************************************************************/
/*
** Define a Tone Response Curve (TRC) table data structure
*/
typedef struct DC_CONIP_TRC_TABLE_CONFIG_STRUCT {
  // pointer to array of tables
  UINT8 *table[DC_CONIP_TRC_TABLE_COUNT];

} DC_CONIP_TRC_TABLE_CONFIG;

/*
** Define a Dither table data structure
*/
typedef struct DC_CONIP_DITHER_TABLE_CONFIG_STRUCT {

  UINT8  extended_mode;   // {0, 1, {2,3}}

  UINT16 width[DC_CONIP_DITHER_TABLE_COUNT];   // 1 <= width <= {128,512}
  UINT16 height[DC_CONIP_DITHER_TABLE_COUNT];  // 1 <= height <= {128, 512}

  UINT16 x_origin;
  UINT16 y_origin;

  UINT16 stride;          // (width + 31) & ~31
  UINT8  modeCodeTrap;    // {0, 1}

  UINT32 *table;           // address of table

  UINT8 replicate;        // {0, 1, 2}
  UINT8 component_index[DC_CONIP_DITHER_COMPONENT_COUNT];  // {0, 1, 2, 3}
  UINT8 class_index[DC_CONIP_DITHER_CLASS_COUNT];          // {0, 1}            

} DC_CONIP_DITHER_TABLE_CONFIG;

/*
** Define a Color Space Conversion table data structure
*/
typedef struct DC_CONIP_CSC_TABLE_DATA_STRUCT {

  UINT8 n_components;

  UINT32 *onchip_table;
  UINT8 *offchip_table;

  UINT8 onchip_lut;         // {0, 1}
  UINT8 lut_size;           // {0=9x9x9, 1=17x17x17, 2=33x33x33}
  UINT8 onchip_speedup;     // {0, 1}

  UINT8 true6Color;         // {0, 1}
  UINT8 cacheEnable;        // {0, 1}
  UINT8 hybridTables;       // {0, 1}

  UINT8 minLattice[3];      // 0 <= minLattice <= 31

  UINT8 hybridThreshold;

} DC_CONIP_CSC_TABLE_DATA;

typedef struct DC_CONIP_CSC_TABLE_CONFIG_STRUCT {

  UINT8 interpolation_type; // {0 = tetrahedral, 1 = trilinear}
  //UINT8 no_satutrate;     // {0, 1}
  //UINT8 mono_on_diagonal; // {0, 1}

  UINT8 unclassified_index;
  UINT8 photoclass_index;
  UINT8 blacktextclass_index;

  DC_CONIP_CSC_TABLE_DATA *csc_table[2];

} DC_CONIP_CSC_TABLE_CONFIG;

/******************************************************************************
*  5. GLOBALS
******************************************************************************/


/******************************************************************************
*  6. PRIVATE FUNCTION PROTOTYPES
******************************************************************************/

DC_RETURN_CODE dc_conip_trc_default_get(DC_CONIP_DATA *pContext, DC_CONIP_TRC_TABLE_CONFIG *cfg);
DC_RETURN_CODE dc_conip_trc_configure(DC_CONIP_DATA *pContext, DC_CONIP_TRC_TABLE_CONFIG *cfg);

DC_RETURN_CODE dc_conip_csc_default_get(DC_CONIP_DATA *pContext, DC_CONIP_CSC_TABLE_CONFIG *cfg);
DC_RETURN_CODE dc_conip_csc_configure(DC_CONIP_DATA *pContext, DC_CONIP_CSC_TABLE_CONFIG *cfg);

DC_RETURN_CODE dc_conip_dither_default_get(DC_CONIP_DATA *pContext, DC_CONIP_DITHER_TABLE_CONFIG *cfg);
DC_RETURN_CODE dc_conip_dither_configure(DC_CONIP_DATA *pContext, DC_CONIP_DITHER_TABLE_CONFIG *cfg);

DC_RETURN_CODE dc_conip_lines2enqueue_get(DC_CONIP_DATA *pContext, \
                                         UINT32 nInputLinesAvailable, \
                                         UINT32 nOutputLinesAvailable, \
                                         UINT32 *nScanLines);

DC_RETURN_CODE dc_conip_input_info_get(DC_CONIP_DATA *pContext, UINT32 *cumulativeInputScanlines);
DC_RETURN_CODE dc_conip_dmap_info_get(DC_CONIP_DATA *pContext,  UINT32 *cumulativeDMAPScanlines);
DC_RETURN_CODE dc_conip_dmap_scanline_add(DC_CONIP_DATA *pContext,  UINT32 nScanlines);

#endif
